"use strict";

var __extends = this && this.__extends || function() {
    var extendStatics = Object.setPrototypeOf || {
        __proto__: []
    } instanceof Array && function(d, b) {
        d.__proto__ = b;
    } || function(d, b) {
        for (var p in b) b.hasOwnProperty(p) && (d[p] = b[p]);
    };
    return function(d, b) {
        function __() {
            this.constructor = d;
        }
        extendStatics(d, b), d.prototype = null === b ? Object.create(b) : (__.prototype = b.prototype, 
        new __());
    };
}();

define("TreemapVisual/treemap", [ "require", "exports", "TreemapVisual/util", "TreemapVisual/treemapAnimator", "TreemapVisual/treemapBehaviors" ], function(require, exports, util, treemapAnimator_1, treemapBehaviors_1) {
    function webAnimator() {
        return new treemapAnimator_1.WebTreemapAnimator();
    }
    function webBehavior() {
        return new treemapBehaviors_1.TreemapWebBehavior();
    }
    Object.defineProperty(exports, "__esModule", {
        value: !0
    });
    var pbi = powerbi, data = pbi.data, visuals = pbi.visuals, AnimatorCommon = visuals.AnimatorCommon, ColorHelper = visuals.ColorHelper, converterHelper = visuals.converterHelper, createDataViewCategoricalReaderAdvanced = data.createDataViewCategoricalReaderAdvanced, LabelUtils = visuals.LabelUtils, dataLabelUtils = visuals.dataLabelUtils, Double = pbi.Double, FontProperties = visuals.FontProperties, FontSize = visuals.Units.FontSize, GradientUtils = visuals.GradientUtils, ObjectEnumerationBuilder = visuals.ObjectEnumerationBuilder, Legend = visuals.Legend, LegendPosition = visuals.LegendPosition, SelectionIdBuilder = visuals.SelectionIdBuilder, SelectionId = visuals.SelectionId, SVGUtil = visuals.SVGUtil, TextMeasurementService = pbi.TextMeasurementService, TooltipBuilder = visuals.TooltipBuilder, ToolTipComponent = visuals.ToolTipComponent, treemapProps = visuals.treemapProps, treemapRoles = visuals.treemapRoles, valueFormatter = visuals.valueFormatter, Treemap = function() {
        function Treemap(options) {
            this.tooltipsEnabled = options && options.tooltipsEnabled, this.touchScreenOptimizedTooltipsEnabled = options && options.touchScreenOptimizedTooltipsEnabled, 
            options && options.animator && (this.animator = options.animator, this.isScrollable = !!options.isScrollable && options.isScrollable, 
            this.behavior = options.behavior, this.customFontFamily = options.customFontFamily, 
            this.customFontFamilyForDataLabel = options.customFontFamilyForDataLabel);
        }
        return Treemap.getLayout = function(dataLabelSettings, alternativeScale, categoryLabelSettings) {
            var formattersCache = LabelUtils.createColumnFormatterCacheManager(), majorLabelsEnabled = categoryLabelSettings.show, minorLabelsEnabled = dataLabelSettings.show;
            return {
                shapeClass: function(d) {
                    return Treemap.getNodeClass(d, !1);
                },
                shapeLayout: Treemap.createTreemapShapeLayout(!1),
                highlightShapeClass: function(d) {
                    return Treemap.getNodeClass(d, !0);
                },
                highlightShapeLayout: Treemap.createTreemapShapeLayout(!0),
                zeroShapeLayout: Treemap.createTreemapZeroShapeLayout(),
                majorLabelClass: function(d) {
                    return util.classes.major;
                },
                majorLabelLayout: {
                    x: function(d) {
                        return d.x + Treemap.TextMargin;
                    },
                    y: function(d) {
                        return d.y + Treemap.TextMargin + categoryLabelSettings.fontProperties.size.px;
                    }
                },
                majorLabelText: function(d) {
                    return Treemap.createMajorLabelText(d, categoryLabelSettings, alternativeScale, formattersCache);
                },
                minorLabelClass: function(d) {
                    return util.classes.minor;
                },
                minorLabelLayout: {
                    x: function(d) {
                        return d.x + Treemap.TextMargin;
                    },
                    y: function(d) {
                        return d.y + d.dy - Treemap.TextMargin;
                    }
                },
                minorLabelText: function(d) {
                    return Treemap.createMinorLabelText(d, dataLabelSettings, alternativeScale, formattersCache, categoryLabelSettings);
                },
                areMajorLabelsEnabled: function() {
                    return majorLabelsEnabled;
                },
                areMinorLabelsEnabled: function() {
                    return minorLabelsEnabled;
                }
            };
        }, Treemap.prototype.init = function(options) {
            this.options = options;
            var element = options.element;
            element.empty(), this.svg = d3.select(element.get(0)).append("svg").style("position", "absolute").classed(Treemap.ClassName, !0), 
            this.shapeGraphicsContext = this.svg.append("g").classed(Treemap.ShapesClassName, !0), 
            this.labelGraphicsContext = this.svg.append("g").classed(Treemap.LabelsGroupClassName, !0), 
            this.element = element, this.currentViewport = {
                height: options.viewport.height,
                width: options.viewport.width
            }, this.style = options.style, this.treemap = d3.layout.treemap().sticky(!1).sort(function(a, b) {
                return a.size - b.size;
            }).value(function(d) {
                return d.size;
            }).round(!1), this.behavior && (this.interactivityService = visuals.createInteractivityService(options.host)), 
            this.legend = visuals.createLegend(element, options.interactivity && options.interactivity.isInteractiveLegend, this.interactivityService, this.isScrollable), 
            this.colors = this.style.colorPalette.dataColors, this.hostService = options.host, 
            this.tooltipService = visuals.createTooltipService(options.host, this.touchScreenOptimizedTooltipsEnabled);
        }, Treemap.getDefaultTreemapDataLabelSettings = function() {
            return {
                show: !1,
                displayUnits: 0,
                precision: dataLabelUtils.defaultLabelPrecision,
                fontProperties: FontProperties.inherit(LabelUtils.defaultFontProperties, {
                    size: FontSize.createFromPx(LabelUtils.defaultTreeMapMinorLabelTextSize),
                    family: LabelUtils.StandardFontFamily,
                    color: LabelUtils.defaultInsideLabelColor
                })
            };
        }, Treemap.getDefaultTreemapCategoryLabelSettings = function() {
            return {
                show: !0,
                fontProperties: FontProperties.inherit(LabelUtils.defaultFontProperties, {
                    size: FontSize.createFromPx(LabelUtils.defaultTreeMapMajorLabelTextSize),
                    family: LabelUtils.StandardFontFamily,
                    color: LabelUtils.defaultInsideLabelColor
                })
            };
        }, Treemap.converter = function(options) {
            var valueColumnRoleName, dataView = options.dataView, style = options.style, dataLabelSettings = options.dataLabelSettings, categoryLabelSettings = options.categoryLabelSettings, interactivityService = options.interactivityService, viewport = options.viewport, legendObjectProperties = options.legendObjectProperties, tooltipsEnabled = null == options.tooltipsEnabled || options.tooltipsEnabled;
            valueColumnRoleName = dataView && dataView.metadata && _.some(dataView.metadata.columns, function(column) {
                return column.roles[treemapRoles.values];
            }) ? treemapRoles.values : treemapRoles.gradient;
            var hasNegativeValues, allValuesAreNegative, hasHighlights, dataWasCulled, reader = createDataViewCategoricalReaderAdvanced(dataView, {
                staticSeriesRole: valueColumnRoleName
            }), dataReader = reader.data, columnReader = reader.columns, rootNode = {
                key: "root",
                name: "root",
                originalValue: void 0,
                children: [],
                selected: !1,
                highlightMultiplier: 0,
                identity: SelectionId.createNull(),
                color: void 0
            }, allNodes = [], legendTitle = "", colorHelper = new ColorHelper(style.colorPalette.dataColors, treemapProps.dataPoint.fill);
            if (dataView && dataView.metadata && dataView.metadata.objects) {
                var objects = dataView.metadata.objects, labelsObj = objects.labels;
                labelsObj && dataLabelSettings && LabelUtils.updateLabelSettingsFromLabelsObject(labelsObj, dataLabelSettings);
                var categoryLabelsObj = objects.categoryLabels;
                categoryLabelsObj && categoryLabelSettings && LabelUtils.updateLabelSettingsFromLabelsObject(categoryLabelsObj, categoryLabelSettings);
            }
            if (dataReader.hasValues(treemapRoles.values) || dataReader.hasValues(treemapRoles.gradient)) {
                var categorical = dataView.categorical;
                hasHighlights = dataReader.hasHighlights();
                var formatStringProp = treemapProps.general.formatString, result = Treemap.getValuesFromCategoricalDataView(dataView, hasHighlights, valueColumnRoleName), values = result.values, highlights = result.highlights, totalValue = result.totalValue;
                result.highlightsOverflow && (hasHighlights = !1, values = highlights), hasNegativeValues = result.hasNegativeValues, 
                allValuesAreNegative = result.allValuesAreNegative;
                var cullableValue = Treemap.getCullableValue(totalValue, viewport), hasDynamicSeries = columnReader.hasDynamicSeries();
                dataWasCulled = !1;
                var gradientValueColumn = columnReader.getValueColumn(treemapRoles.gradient, 0);
                if (null != categorical.categories || _.isEmpty(values)) {
                    if (categorical.categories && categorical.categories.length > 0) {
                        var seriesCount = dataReader.getSeriesCount(), omitSecondLevel = !dataReader.hasSeries(), categoryColumn = categorical.categories[0];
                        legendTitle = categoryColumn.source.displayName;
                        for (var categoryFormat = valueFormatter.getFormatString(categoryColumn.source, formatStringProp), categoryIndex = 0, categoryLen = values.length; categoryIndex < categoryLen; categoryIndex++) {
                            var objects = categoryColumn.objects && categoryColumn.objects[categoryIndex], color = colorHelper.getColorForSeriesValue(objects, categoryColumn.identityFields, categoryColumn.values[categoryIndex]), categoryValue = valueFormatter.format(categoryColumn.values[categoryIndex], categoryFormat), currentValues = values[categoryIndex], seriesIndex = 0, value = currentValues[seriesIndex], highlightValue = hasHighlights && highlights ? highlights[categoryIndex][seriesIndex] : void 0, tooltipInfo = void 0, categoryTooltipItem = void 0;
                            if (tooltipsEnabled) {
                                if (tooltipInfo = [], categoryTooltipItem = {
                                    displayName: categoryColumn.source.displayName,
                                    value: categoryValue
                                }, tooltipInfo.push(categoryTooltipItem), hasDynamicSeries) {
                                    var seriesMetadataColumn = columnReader.getSeriesMetadataColumn(), seriesValue = dataReader.getSeriesName(seriesIndex);
                                    tooltipInfo.push({
                                        displayName: seriesMetadataColumn.displayName,
                                        value: converterHelper.formatFromMetadataColumn(seriesValue, seriesMetadataColumn, formatStringProp)
                                    });
                                }
                                var valueColumnMetadata = columnReader.getValueMetadataColumn(valueColumnRoleName, seriesIndex);
                                null != value && tooltipInfo.push({
                                    displayName: valueColumnMetadata.displayName,
                                    value: converterHelper.formatFromMetadataColumn(value, valueColumnMetadata, formatStringProp, !1)
                                }), null != highlightValue && tooltipInfo.push({
                                    displayName: ToolTipComponent.localizationOptions.highlightedValueDisplayName,
                                    value: converterHelper.formatFromMetadataColumn(highlightValue, valueColumnMetadata, formatStringProp, !1)
                                });
                                var gradientValueColumnMetadata = gradientValueColumn ? gradientValueColumn.source : void 0;
                                omitSecondLevel && gradientValueColumnMetadata && gradientValueColumnMetadata !== valueColumnMetadata && null != gradientValueColumn.values[categoryIndex] && tooltipInfo.push({
                                    displayName: gradientValueColumnMetadata.displayName,
                                    value: converterHelper.formatFromMetadataColumn(gradientValueColumn.values[categoryIndex], gradientValueColumnMetadata, formatStringProp, !1)
                                }), TooltipBuilder.addTooltipMeasures(reader, tooltipInfo, categoryIndex, seriesIndex, formatStringProp);
                            }
                            var valueMetadataColumn = columnReader.getValueMetadataColumn(valueColumnRoleName, seriesIndex), identity = SelectionIdBuilder.builder().withCategory(categoryColumn, categoryIndex).withMeasure(omitSecondLevel && valueMetadataColumn ? valueMetadataColumn.queryName : void 0).createSelectionId(), key = JSON.stringify({
                                nodeKey: identity.getKey(),
                                depth: 1
                            }), node = {
                                key: key,
                                name: categoryValue,
                                originalValue: void 0,
                                color: color,
                                selected: !1,
                                identity: identity,
                                tooltipInfo: tooltipInfo,
                                highlightedTooltipInfo: tooltipInfo,
                                labelFormatString: 1 === seriesCount ? valueFormatter.getFormatString(columnReader.getValueMetadataColumn(valueColumnRoleName, seriesIndex), formatStringProp) : categoryFormat
                            };
                            hasHighlights && (node.highlightMultiplier = 0 !== value ? highlightValue / value : 0, 
                            node.highlightValue = allValuesAreNegative && null != highlightValue ? Math.abs(highlightValue) : highlightValue, 
                            node.originalHighlightValue = highlightValue);
                            for (var total = 0, highlightTotal = 0; seriesIndex < seriesCount; seriesIndex++) {
                                var valueColumn = columnReader.getValueColumn(valueColumnRoleName, seriesIndex), value_1 = currentValues[seriesIndex], highlight = void 0, valueShape = Treemap.checkValueForShape(value_1, cullableValue, allValuesAreNegative, dataWasCulled);
                                if (dataWasCulled = valueShape.dataWasCulled, valueShape.validShape && (total += value_1, 
                                hasHighlights && (highlight = highlights[categoryIndex][seriesIndex], highlightTotal += highlight), 
                                !omitSecondLevel)) {
                                    var childName = null;
                                    childName = columnReader.hasDynamicSeries() ? converterHelper.formatFromMetadataColumn(dataReader.getSeriesName(seriesIndex), columnReader.getSeriesMetadataColumn(), formatStringProp) : reader.data.getSeriesName(seriesIndex);
                                    var categoricalValues = categorical ? categorical.values : null, measureId = valueColumn.source.queryName, childIdentity = SelectionIdBuilder.builder().withCategory(categoryColumn, categoryIndex).withSeries(categoricalValues, valueColumn).withMeasure(measureId).createSelectionId(), childKey = JSON.stringify({
                                        nodeKey: childIdentity.getKey(),
                                        depth: 2
                                    }), highlightedValue = hasHighlights && 0 !== highlight ? highlight : void 0, tooltipInfo_1 = void 0;
                                    tooltipsEnabled && (tooltipInfo_1 = [], tooltipInfo_1.push(categoryTooltipItem), 
                                    hasDynamicSeries && (categoryColumn && categoryColumn.source === categoricalValues.source || tooltipInfo_1.push({
                                        displayName: categoricalValues.source.displayName,
                                        value: converterHelper.formatFromMetadataColumn(dataReader.getSeriesName(seriesIndex), categoricalValues.source, formatStringProp)
                                    })), null != value_1 && tooltipInfo_1.push({
                                        displayName: valueColumn.source.displayName,
                                        value: converterHelper.formatFromMetadataColumn(value_1, valueColumn.source, formatStringProp, !1)
                                    }), null != highlightValue && tooltipInfo_1.push({
                                        displayName: ToolTipComponent.localizationOptions.highlightedValueDisplayName,
                                        value: converterHelper.formatFromMetadataColumn(highlightedValue, valueColumn.source, formatStringProp, !1)
                                    }), TooltipBuilder.addTooltipMeasures(reader, tooltipInfo_1, categoryIndex, hasDynamicSeries ? seriesIndex : void 0, formatStringProp));
                                    var childNode = {
                                        key: childKey,
                                        name: childName,
                                        size: allValuesAreNegative ? Math.abs(value_1) : value_1,
                                        originalValue: value_1,
                                        color: color,
                                        selected: !1,
                                        identity: childIdentity,
                                        tooltipInfo: tooltipInfo_1,
                                        highlightedTooltipInfo: tooltipInfo_1,
                                        labelFormatString: valueFormatter.getFormatString(valueColumn.source, formatStringProp)
                                    };
                                    hasHighlights && (childNode.highlightMultiplier = 0 !== value_1 ? highlight / value_1 : 0, 
                                    childNode.highlightValue = allValuesAreNegative && null != highlight ? Math.abs(highlight) : null, 
                                    childNode.originalHighlightValue = highlight), null == node.children && (node.children = []), 
                                    node.children.push(childNode), allNodes.push(childNode);
                                }
                            }
                            total && (node.size = allValuesAreNegative ? Math.abs(total) : total, node.originalValue = total, 
                            rootNode.children.push(node), allNodes.push(node)), hasHighlights && (node.highlightMultiplier = total ? highlightTotal / total : 0);
                        }
                    }
                } else for (var seriesIndex = 0, seriesCount = columnReader.getSeriesCount(); seriesIndex < seriesCount; seriesIndex++) {
                    var valueColumn = columnReader.getValueColumn(valueColumnRoleName, seriesIndex), value = values[0][seriesIndex], valueShape = Treemap.checkValueForShape(value, cullableValue, allValuesAreNegative, dataWasCulled);
                    if (dataWasCulled = valueShape.dataWasCulled, valueShape.validShape) {
                        var nodeName = void 0;
                        nodeName = hasDynamicSeries ? converterHelper.formatFromMetadataColumn(columnReader.getSeriesValueColumnGroup(seriesIndex).name, columnReader.getSeriesMetadataColumn(), formatStringProp) : reader.columns.hasStaticSeries() ? reader.data.getSeriesName(seriesIndex) : reader.data.getValueDisplayName(valueColumnRoleName);
                        var identity = new SelectionIdBuilder().withSeries(dataView.categorical.values, hasDynamicSeries ? valueColumn : void 0).withMeasure(valueColumn.source.queryName).createSelectionId(), key = identity.getKey(), color = hasDynamicSeries ? colorHelper.getColorForSeriesValue(reader.objects.getSeriesDataObjects(seriesIndex), categorical.values.identityFields, converterHelper.getSeriesName(valueColumn.source)) : colorHelper.getColorForMeasure(valueColumn.source.objects, valueColumn.source.queryName), highlightedValue = hasHighlights ? highlights[0][seriesIndex] : void 0, tooltipInfo = void 0;
                        if (tooltipsEnabled) {
                            if (tooltipInfo = [], hasDynamicSeries) {
                                var seriesMetadataColumn = columnReader.getSeriesMetadataColumn(), seriesValue = dataReader.getSeriesName(seriesIndex);
                                tooltipInfo.push({
                                    displayName: seriesMetadataColumn.displayName,
                                    value: converterHelper.formatFromMetadataColumn(seriesValue, seriesMetadataColumn, formatStringProp)
                                });
                            }
                            null != value && tooltipInfo.push({
                                displayName: valueColumn.source.displayName,
                                value: converterHelper.formatFromMetadataColumn(value, valueColumn.source, formatStringProp, !1)
                            }), null != highlightedValue && tooltipInfo.push({
                                displayName: ToolTipComponent.localizationOptions.highlightedValueDisplayName,
                                value: converterHelper.formatFromMetadataColumn(highlightedValue, valueColumn.source, formatStringProp, !1)
                            }), TooltipBuilder.addTooltipMeasures(reader, tooltipInfo, 0, hasDynamicSeries ? seriesIndex : void 0, formatStringProp);
                        }
                        var node = {
                            key: key,
                            name: nodeName,
                            size: allValuesAreNegative ? Math.abs(value) : value,
                            originalValue: value,
                            color: color,
                            selected: !1,
                            identity: identity,
                            tooltipInfo: tooltipInfo,
                            highlightedTooltipInfo: tooltipInfo,
                            labelFormatString: valueFormatter.getFormatString(valueColumn.source, formatStringProp)
                        };
                        hasHighlights && highlights && (node.highlightMultiplier = 0 !== value ? highlightedValue / value : 0, 
                        node.highlightValue = allValuesAreNegative && null != highlightedValue ? Math.abs(highlightedValue) : highlightedValue, 
                        node.originalHighlightValue = highlightedValue), rootNode.children.push(node), allNodes.push(node);
                    }
                }
            }
            var legendData;
            return legendData = reader.data.hasCategories() ? Legend.buildCategoryLegendData({
                dataView: dataView,
                categoryRole: treemapRoles.group,
                valueRole: treemapRoles.values,
                showByDefault: !1,
                style: style
            }) : Legend.buildSeriesLegendData({
                dataView: dataView,
                staticSeriesRole: treemapRoles.values,
                showByDefault: !1,
                style: style
            }), interactivityService && (interactivityService.applySelectionStateToData(allNodes), 
            interactivityService.applySelectionStateToData(legendData.dataPoints)), {
                root: rootNode,
                hasHighlights: hasHighlights,
                legendData: legendData,
                dataLabelSettings: dataLabelSettings,
                categoryLabelSettings: categoryLabelSettings,
                legendObjectProperties: legendObjectProperties,
                dataWasCulled: dataWasCulled,
                hasNegativeValues: hasNegativeValues,
                allValuesAreNegative: allValuesAreNegative
            };
        }, Treemap.normalizedValue = function(value, allValuesAreNegative) {
            return null == value || isNaN(value) ? 0 : value === Number.POSITIVE_INFINITY ? Number.MAX_VALUE : value === Number.NEGATIVE_INFINITY ? -Number.MAX_VALUE : allValuesAreNegative ? Math.abs(value) : value < 0 ? 0 : value;
        }, Treemap.getValuesFromCategoricalDataView = function(dataView, hasHighlights, valueColumnRoleName) {
            for (var reader = createDataViewCategoricalReaderAdvanced(dataView, {
                staticSeriesRole: valueColumnRoleName
            }), dataReader = reader.data, categoryCount = dataReader.getCategoryCount() || 1, seriesCount = dataReader.getSeriesCount(), values = [], highlights = [], totalValue = 0, i = 0; i < categoryCount; i++) values.push([]), 
            hasHighlights && highlights.push([]);
            for (var hasNegativeValues, allValuesAreNegative, highlightsOverflow, seriesIndex = 0; seriesIndex < seriesCount; seriesIndex++) for (var categoryIndex = 0; categoryIndex < categoryCount; categoryIndex++) {
                var value = dataReader.getValue(valueColumnRoleName, categoryIndex, seriesIndex);
                values[categoryIndex].push(value);
                var highlight = void 0;
                hasHighlights && (highlight = dataReader.getHighlight(valueColumnRoleName, categoryIndex, seriesIndex), 
                highlights[categoryIndex].push(highlight), null == highlight && (highlight = 0)), 
                allValuesAreNegative = void 0 === allValuesAreNegative ? (!hasHighlights || highlight <= 0) && value <= 0 : allValuesAreNegative && (!hasHighlights || highlight <= 0) && value <= 0, 
                hasNegativeValues || (hasNegativeValues = value < 0 || !!hasHighlights && highlight < 0);
            }
            allValuesAreNegative = !!allValuesAreNegative;
            for (var seriesIndex = 0; seriesIndex < seriesCount; seriesIndex++) for (var categoryIndex = 0; categoryIndex < categoryCount; categoryIndex++) {
                var value = values[categoryIndex][seriesIndex];
                if (value = Treemap.normalizedValue(value, allValuesAreNegative), totalValue += value, 
                hasHighlights) {
                    var highlight = highlights[categoryIndex][seriesIndex];
                    highlight = Treemap.normalizedValue(highlight, allValuesAreNegative), !highlightsOverflow && Double.greaterWithPrecision(highlight, value) && (highlightsOverflow = !0);
                }
            }
            return {
                values: values,
                highlights: hasHighlights ? highlights : void 0,
                highlightsOverflow: hasHighlights ? highlightsOverflow : void 0,
                totalValue: allValuesAreNegative ? Math.abs(totalValue) : totalValue,
                hasNegativeValues: hasNegativeValues,
                allValuesAreNegative: allValuesAreNegative
            };
        }, Treemap.getCullableValue = function(totalValue, viewport) {
            var totalArea = viewport.width * viewport.height, culledPercent = Treemap.CullableArea / totalArea;
            return culledPercent * totalValue;
        }, Treemap.prototype.update = function(options) {
            var dataViews = this.dataViews = options.dataViews;
            this.currentViewport = options.viewport;
            var dataViewCategorical = dataViews && dataViews.length > 0 && dataViews[0].categorical ? dataViews[0].categorical : void 0, dataLabelSettings = Treemap.getDefaultTreemapDataLabelSettings(), categoryLabelSettings = Treemap.getDefaultTreemapCategoryLabelSettings(), legendObjectProperties = null;
            if (dataViewCategorical) {
                var dataView = dataViews[0], dataViewMetadata = dataView.metadata, objects = void 0;
                dataViewMetadata && (objects = dataViewMetadata.objects), objects && (legendObjectProperties = objects.legend), 
                this.data = Treemap.converter({
                    dataView: dataView,
                    style: this.style,
                    dataLabelSettings: dataLabelSettings,
                    categoryLabelSettings: categoryLabelSettings,
                    interactivityService: this.interactivityService,
                    viewport: this.currentViewport,
                    legendObjectProperties: legendObjectProperties,
                    tooltipsEnabled: this.tooltipsEnabled
                });
            } else {
                var rootNode = {
                    key: "root",
                    name: "root",
                    originalValue: void 0,
                    children: [],
                    selected: !1,
                    highlightMultiplier: 0,
                    identity: SelectionId.createNull(),
                    color: void 0
                }, legendData = Legend.getDefaultLegendData(), treeMapData = {
                    root: rootNode,
                    hasHighlights: !1,
                    legendData: legendData,
                    dataLabelSettings: dataLabelSettings,
                    categoryLabelSettings: categoryLabelSettings,
                    dataWasCulled: !1,
                    hasNegativeValues: !1,
                    allValuesAreNegative: !1
                };
                this.data = treeMapData;
            }
            if (this.updateInternal(options.suppressAnimations), dataViews) {
                var warnings = visuals.getInvalidValueWarnings(dataViews, !1, !1, !1, [ "Tooltips" ]);
                this.data.allValuesAreNegative ? warnings.push(new visuals.AllNegativeValuesWarning()) : this.data.hasNegativeValues && warnings.push(new visuals.NegativeValuesNotSupportedWarning()), 
                this.hostService.setWarnings(warnings);
            }
        }, Treemap.prototype.onDataChanged = function(options) {
            this.update({
                suppressAnimations: options.suppressAnimations,
                dataViews: options.dataViews,
                viewport: this.currentViewport
            });
        }, Treemap.prototype.onResizing = function(viewport) {
            this.update({
                suppressAnimations: !0,
                dataViews: this.dataViews,
                viewport: viewport
            });
        }, Treemap.prototype.onClearSelection = function() {
            this.interactivityService && this.interactivityService.clearSelection();
        }, Treemap.prototype.getDataLabelSettingsOptions = function(enumeration, labelSettings, isNum) {
            return {
                enumeration: enumeration,
                dataLabelsSettings: labelSettings,
                show: !0,
                displayUnits: isNum,
                precision: isNum,
                fontSize: this.customFontFamilyForDataLabel,
                fontFamily: this.customFontFamilyForDataLabel
            };
        }, Treemap.prototype.enumerateObjectInstances = function(options) {
            var data = this.data;
            if (data) {
                var objectName = options.objectName, enumeration = new ObjectEnumerationBuilder(), dataLabelsSettings = this.data.dataLabelSettings, categoryLabelsSettings = this.data.categoryLabelSettings;
                switch (objectName) {
                  case "dataPoint":
                    var dataViewCat = this.dataViews && this.dataViews.length > 0 && this.dataViews[0] && this.dataViews[0].categorical, hasGradientRole = GradientUtils.hasGradientRole(dataViewCat);
                    hasGradientRole || this.enumerateDataPoints(enumeration, data);
                    break;

                  case "legend":
                    Legend.enumerate({
                        enumeration: enumeration,
                        legendData: this.data.legendData,
                        customFontFamily: this.customFontFamily
                    });
                    break;

                  case "labels":
                    var labelSettingOptions = this.getDataLabelSettingsOptions(enumeration, dataLabelsSettings, !0);
                    LabelUtils.enumerateDataLabels(labelSettingOptions);
                    break;

                  case "categoryLabels":
                    var categoryLabelSettingOptions = this.getDataLabelSettingsOptions(enumeration, categoryLabelsSettings, !1);
                    LabelUtils.enumerateDataLabels(categoryLabelSettingOptions);
                }
                return enumeration.complete();
            }
        }, Treemap.prototype.enumerateDataPoints = function(enumeration, data) {
            var rootChildren = data.root.children;
            if (!_.isEmpty(rootChildren)) for (var _i = 0, _a = rootChildren; _i < _a.length; _i++) {
                var treemapNode = _a[_i];
                enumeration.pushInstance({
                    displayName: treemapNode.name,
                    selector: ColorHelper.normalizeSelector(treemapNode.identity.getSelector()),
                    properties: {
                        fill: {
                            solid: {
                                color: treemapNode.color
                            }
                        }
                    },
                    objectName: "dataPoint"
                });
            }
        }, Treemap.checkValueForShape = function(value, cullableValue, allValuesAreNegative, dataWasCulled) {
            var shouldCullValue;
            return value ? (shouldCullValue = allValuesAreNegative ? Math.abs(value) < cullableValue : value < cullableValue, 
            shouldCullValue ? (dataWasCulled = dataWasCulled || shouldCullValue, {
                validShape: !1,
                dataWasCulled: dataWasCulled
            }) : {
                validShape: !0,
                dataWasCulled: dataWasCulled
            }) : {
                validShape: !1,
                dataWasCulled: dataWasCulled
            };
        }, Treemap.prototype.calculateTreemapSize = function() {
            var legendMargins = this.legend.getMargins();
            return {
                height: this.currentViewport.height - legendMargins.height,
                width: this.currentViewport.width - legendMargins.width
            };
        }, Treemap.prototype.initViewportDependantProperties = function(duration) {
            void 0 === duration && (duration = 0);
            var viewport = this.calculateTreemapSize();
            this.svg.attr({
                width: viewport.width,
                height: viewport.height
            }), Legend.positionChartArea(this.svg, this.legend), SVGUtil.flushAllD3TransitionsIfNeeded(this.options);
        }, Treemap.canDisplayMajorLabel = function(node, labelSettings) {
            if (1 !== node.depth) return !1;
            if (_.isEmpty(node.name)) return !1;
            var availableWidth = node.dx - 2 * Treemap.TextMargin;
            if (availableWidth < Treemap.MinTextWidthForMajorLabel) return !1;
            var textHeightWithMargin = labelSettings.fontProperties.size.px + 2 * Treemap.TextMargin;
            return !(node.dy < textHeightWithMargin);
        }, Treemap.canDisplayMinorLabel = function(node, dataLabelSettings, categoryLabelSettings) {
            if (node.depth < 1 || node.depth > 2) return !1;
            if (1 === node.depth && (node.children || !dataLabelSettings.show)) return !1;
            if (_.isEmpty(node.name)) return !1;
            var availableWidth = node.dx - 2 * Treemap.TextMargin;
            if (availableWidth < Treemap.MinTextWidthForMinorLabel) return !1;
            var textHeightWithMargin = dataLabelSettings.fontProperties.size.px + 2 * Treemap.TextMargin;
            if (node.dy < textHeightWithMargin) return !1;
            if (1 === node.depth) {
                var roomTop = node.y + categoryLabelSettings.fontProperties.size.px + 2 * Treemap.TextMargin;
                if (node.y + node.dy - roomTop < textHeightWithMargin) return !1;
            } else if (2 === node.depth) {
                var parent_1 = node.parent, roomTop = Math.max(parent_1.y + categoryLabelSettings.fontProperties.size.px + 2 * Treemap.TextMargin, node.y);
                if (node.y + node.dy - roomTop < textHeightWithMargin) return !1;
            }
            return !0;
        }, Treemap.createMajorLabelText = function(node, labelsSettings, alternativeScale, formattersCache) {
            var spaceAvaliableForLabels = node.dx - 2 * Treemap.TextMargin, textProperties = FontProperties.toTextProperties(labelsSettings.fontProperties, node.name);
            return TextMeasurementService.getTailoredTextOrDefault(textProperties, spaceAvaliableForLabels);
        }, Treemap.createMinorLabelText = function(node, dataLabelsSettings, alternativeScale, formattersCache, categoryLabelsSettings) {
            var spaceAvaliableForLabels = node.dx - 2 * Treemap.TextMargin, label = node.name;
            if (dataLabelsSettings.show) {
                var measureFormatter = formattersCache.getOrCreate(node.labelFormatString, dataLabelsSettings, alternativeScale);
                label = LabelUtils.getLabelTailoredText({
                    label: null != node.originalHighlightValue ? node.originalHighlightValue : node.originalValue,
                    maxWidth: spaceAvaliableForLabels,
                    formatter: measureFormatter,
                    fontProperties: dataLabelsSettings.fontProperties
                }), categoryLabelsSettings.show && 2 === node.depth && (label = LabelUtils.getLabelTailoredText({
                    label: node.name,
                    maxWidth: spaceAvaliableForLabels,
                    fontProperties: dataLabelsSettings.fontProperties
                }) + " " + label);
            }
            return LabelUtils.getLabelTailoredText({
                label: label,
                maxWidth: spaceAvaliableForLabels,
                fontProperties: dataLabelsSettings.fontProperties
            });
        }, Treemap.prototype.updateInternal = function(suppressAnimations) {
            var data = this.data, hasHighlights = data && data.hasHighlights, dataLabelSettings = data ? data.dataLabelSettings : Treemap.getDefaultTreemapDataLabelSettings(), categoryLabelsSettings = data ? data.categoryLabelSettings : Treemap.getDefaultTreemapCategoryLabelSettings(), duration = AnimatorCommon.GetAnimationDuration(this.animator, suppressAnimations);
            this.options.interactivity && this.options.interactivity.isInteractiveLegend || !this.data || this.renderLegend(), 
            this.initViewportDependantProperties(duration);
            var viewport = this.calculateTreemapSize();
            this.treemap.size([ viewport.width, viewport.height ]);
            var nodes = data && data.root ? this.treemap.nodes(data.root) : [], highlightNodes = nodes.filter(function(value) {
                return null != value.highlightMultiplier && (!value.children || 0 === value.children.length);
            }), majorLabeledNodes = [], minorLabeledNodes = [], alternativeScale = null;
            categoryLabelsSettings.show && (majorLabeledNodes = nodes.filter(function(d) {
                return Treemap.canDisplayMajorLabel(d, categoryLabelsSettings);
            })), (dataLabelSettings.show || categoryLabelsSettings.show) && (minorLabeledNodes = nodes.filter(function(d) {
                return Treemap.canDisplayMinorLabel(d, dataLabelSettings, categoryLabelsSettings);
            }), 0 === dataLabelSettings.displayUnits && (alternativeScale = d3.max(minorLabeledNodes, function(d) {
                return Math.abs(d.value);
            })));
            var shapes, highlightShapes, majorLabels, minorLabels, result, treemapLayout = Treemap.getLayout(dataLabelSettings, alternativeScale, categoryLabelsSettings);
            if (this.animator && !suppressAnimations) {
                var options = {
                    viewModel: data,
                    nodes: nodes,
                    highlightNodes: highlightNodes,
                    majorLabeledNodes: majorLabeledNodes,
                    minorLabeledNodes: minorLabeledNodes,
                    shapeGraphicsContext: this.shapeGraphicsContext,
                    labelGraphicsContext: this.labelGraphicsContext,
                    interactivityService: this.interactivityService,
                    layout: treemapLayout,
                    dataLabelSettings: dataLabelSettings,
                    categoryLabelSettings: categoryLabelsSettings
                };
                result = this.animator.animate(options), shapes = result.shapes, highlightShapes = result.highlightShapes, 
                majorLabels = result.majorLabels, minorLabels = result.minorLabels;
            }
            if (!this.animator || suppressAnimations || result.failed) {
                var hasSelection = this.interactivityService && this.interactivityService.hasSelection(), shapeGraphicsContext = this.shapeGraphicsContext;
                shapes = Treemap.drawDefaultShapes(shapeGraphicsContext, nodes, hasSelection, hasHighlights, treemapLayout), 
                highlightShapes = Treemap.drawDefaultHighlightShapes(shapeGraphicsContext, highlightNodes, hasSelection, hasHighlights, treemapLayout);
                var labelGraphicsContext = this.labelGraphicsContext;
                majorLabels = Treemap.drawDefaultMajorLabels(labelGraphicsContext, majorLabeledNodes, categoryLabelsSettings, treemapLayout), 
                minorLabels = Treemap.drawDefaultMinorLabels(labelGraphicsContext, minorLabeledNodes, dataLabelSettings, treemapLayout);
            }
            if (this.interactivityService) {
                var behaviorOptions = {
                    shapes: shapes,
                    highlightShapes: highlightShapes,
                    majorLabels: majorLabels,
                    minorLabels: minorLabels,
                    nodes: nodes,
                    hasHighlights: data.hasHighlights
                };
                this.interactivityService.bind(nodes, this.behavior, behaviorOptions);
            }
            this.tooltipsEnabled && this.addTooltips(shapes, highlightShapes), SVGUtil.flushAllD3TransitionsIfNeeded(this.options);
        }, Treemap.prototype.addTooltips = function(shapes, highlightShapes) {
            this.tooltipService.addTooltip(shapes, function(args) {
                return args.data && (args.data.highlightedTooltipInfo ? args.data.highlightedTooltipInfo : args.data.tooltipInfo);
            }, function(args) {
                return args.data && args.data.identity;
            }), this.tooltipService.addTooltip(highlightShapes, function(args) {
                return args.data && args.data.highlightedTooltipInfo;
            }, function(args) {
                return args.data && args.data.identity;
            });
        }, Treemap.prototype.renderLegend = function() {
            var legendObjectProperties = this.data.legendObjectProperties;
            if (legendObjectProperties) {
                var legendData = this.data.legendData;
                null != legendData.position && this.legend.changeOrientation(legendData.position), 
                this.legend.drawLegend(legendData, this.currentViewport);
            } else this.legend.changeOrientation(LegendPosition.Top), this.legend.drawLegend(Legend.getDefaultLegendData(), this.currentViewport);
        }, Treemap.getNodeClass = function(d, highlight) {
            var nodeClass;
            switch (d.depth) {
              case 1:
                nodeClass = Treemap.ParentGroupClassName;
                break;

              case 2:
                nodeClass = Treemap.NodeGroupClassName;
                break;

              case 0:
                nodeClass = Treemap.RootNodeClassName;
            }
            return nodeClass += " " + (highlight ? util.classes.highlight : util.classes.node);
        }, Treemap.createTreemapShapeLayout = function(isHighlightRect) {
            if (void 0 === isHighlightRect && (isHighlightRect = !1), isHighlightRect) {
                var highlightAdjustment_1 = .2, highlightStrokeAdjustment_1 = .6;
                return {
                    x: function(d) {
                        return d.x + highlightAdjustment_1;
                    },
                    y: function(d) {
                        return d.y + d.dy * (1 - d.highlightMultiplier);
                    },
                    width: function(d) {
                        return Math.max(0, d.dx - 2 * highlightAdjustment_1);
                    },
                    height: function(d) {
                        return Math.max(0, d.dy * d.highlightMultiplier);
                    },
                    "stroke-dasharray": function(d) {
                        return highlightStrokeAdjustment_1 + "," + (d.dx - 2 * highlightStrokeAdjustment_1) + "," + (2 * d.dy + d.dx);
                    }
                };
            }
            return {
                x: function(d) {
                    return d.x;
                },
                y: function(d) {
                    return d.y;
                },
                width: function(d) {
                    return Math.max(0, d.dx);
                },
                height: function(d) {
                    return Math.max(0, d.dy);
                },
                "stroke-dasharray": null
            };
        }, Treemap.createTreemapZeroShapeLayout = function() {
            return {
                x: function(d) {
                    return d.x;
                },
                y: function(d) {
                    return d.y + d.dy;
                },
                width: function(d) {
                    return Math.max(0, d.dx);
                },
                height: function(d) {
                    return 0;
                }
            };
        }, Treemap.drawDefaultShapes = function(context, nodes, hasSelection, hasHighlights, layout) {
            var isHighlightShape = !1, shapes = context.selectAll("." + util.classes.node).data(nodes, function(d) {
                return d.key;
            });
            return shapes.enter().append("rect").attr("class", layout.shapeClass), shapes.style("fill", function(d) {
                return util.getFill(d, isHighlightShape);
            }).style("fill-opacity", function(d) {
                return util.getFillOpacity(d, hasSelection, hasHighlights, isHighlightShape);
            }).attr(layout.shapeLayout), shapes.exit().remove(), shapes;
        }, Treemap.drawDefaultHighlightShapes = function(context, nodes, hasSelection, hasHighlights, layout) {
            var isHighlightShape = !0, highlightShapes = context.selectAll("." + util.classes.highlight).data(nodes, function(d) {
                return d.key + "highlight";
            });
            return highlightShapes.enter().append("rect").attr("class", layout.highlightShapeClass), 
            highlightShapes.style("fill", function(d) {
                return util.getFill(d, isHighlightShape);
            }).style("fill-opacity", function(d) {
                return util.getFillOpacity(d, hasSelection, hasHighlights, isHighlightShape);
            }).attr(layout.highlightShapeLayout), highlightShapes.exit().remove(), highlightShapes;
        }, Treemap.drawDefaultMajorLabels = function(context, nodes, labelSettings, layout) {
            var labels = context.selectAll("." + util.classes.major).data(nodes, function(d) {
                return d.key;
            });
            return labels.enter().append("text").attr("class", layout.majorLabelClass), labels.attr(layout.majorLabelLayout).text(layout.majorLabelText).style(visuals.FontProperties.toSVGStyle(labelSettings.fontProperties)), 
            labels.exit().remove(), labels;
        }, Treemap.drawDefaultMinorLabels = function(context, nodes, labelSettings, layout) {
            var labels = context.selectAll("." + util.classes.minor).data(nodes, function(d) {
                return d.key;
            });
            return labels.enter().append("text").attr("class", layout.minorLabelClass), labels.attr(layout.minorLabelLayout).text(layout.minorLabelText).style(visuals.FontProperties.toSVGStyle(labelSettings.fontProperties)), 
            labels.exit().remove(), labels;
        }, Treemap.cleanMinorLabels = function(context) {
            var empty = [], labels = context.selectAll("." + Treemap.LabelsGroupClassName).selectAll("." + util.classes.minor).data(empty);
            labels.exit().remove();
        }, Treemap.ClassName = "treemap", Treemap.LabelsGroupClassName = "labels", Treemap.ShapesClassName = "shapes", 
        Treemap.RootNodeClassName = "rootNode", Treemap.ParentGroupClassName = "parentGroup", 
        Treemap.NodeGroupClassName = "nodeGroup", Treemap.MinTextWidthForMinorLabel = 18, 
        Treemap.MinTextWidthForMajorLabel = 22, Treemap.TextMargin = 5, Treemap.CullableArea = 9, 
        Treemap;
    }();
    exports.Treemap = Treemap, exports.webAnimator = webAnimator, exports.webBehavior = webBehavior;
}), define("TreemapVisual/treemapAnimator", [ "require", "exports", "TreemapVisual/util" ], function(require, exports, util) {
    Object.defineProperty(exports, "__esModule", {
        value: !0
    });
    var pbi = powerbi, visuals = pbi.visuals, ColumnUtil = visuals.ColumnUtil, BaseAnimator = visuals.BaseAnimator, WebTreemapAnimator = function(_super) {
        function WebTreemapAnimator(options) {
            return _super.call(this, options) || this;
        }
        return __extends(WebTreemapAnimator, _super), WebTreemapAnimator.prototype.animate = function(options) {
            var result = {
                failed: !0,
                shapes: null,
                highlightShapes: null,
                majorLabels: null,
                minorLabels: null
            }, viewModel = options.viewModel, previousViewModel = this.previousViewModel;
            return previousViewModel && (viewModel.hasHighlights && !previousViewModel.hasHighlights ? result = this.animateNormalToHighlighted(options) : viewModel.hasHighlights && previousViewModel.hasHighlights ? result = this.animateHighlightedToHighlighted(options) : !viewModel.hasHighlights && previousViewModel.hasHighlights && (result = this.animateHighlightedToNormal(options))), 
            this.previousViewModel = viewModel, result;
        }, WebTreemapAnimator.prototype.animateNormalToHighlighted = function(options) {
            var hasSelection = !1, hasHighlights = !0, shapes = this.animateDefaultShapes(options.shapeGraphicsContext, options.nodes, hasSelection, hasHighlights, options.layout), highlightShapes = options.shapeGraphicsContext.selectAll("." + util.classes.highlight).data(options.highlightNodes, function(d) {
                return d.key + "highlight";
            });
            highlightShapes.enter().append("rect").attr("class", options.layout.highlightShapeClass).attr(options.layout.shapeLayout), 
            highlightShapes.style("fill", function(d) {
                return util.getFill(d, !0);
            }).style("fill-opacity", function(d) {
                return util.getFillOpacity(d, hasSelection, hasHighlights, !0);
            }).transition().duration(this.animationDuration).attr(options.layout.highlightShapeLayout), 
            highlightShapes.exit().remove();
            var majorLabels = this.animateDefaultMajorLabels(options.labelGraphicsContext, options.majorLabeledNodes, options.categoryLabelSettings, options.layout), minorLabels = this.animateDefaultMinorLabels(options.labelGraphicsContext, options.minorLabeledNodes, options.dataLabelSettings, options.layout);
            return {
                failed: !1,
                shapes: shapes,
                highlightShapes: highlightShapes,
                majorLabels: majorLabels,
                minorLabels: minorLabels
            };
        }, WebTreemapAnimator.prototype.animateHighlightedToHighlighted = function(options) {
            var hasSelection = !1, hasHighlights = !0, shapes = this.animateDefaultShapes(options.shapeGraphicsContext, options.nodes, hasSelection, hasHighlights, options.layout);
            options.shapeGraphicsContext.selectAll("." + util.classes.highlight).data(options.highlightNodes, function(d) {
                return d.key + "highlight";
            });
            var highlightShapes = this.animateDefaultHighlightShapes(options.shapeGraphicsContext, options.highlightNodes, hasSelection, hasHighlights, options.layout), majorLabels = this.animateDefaultMajorLabels(options.labelGraphicsContext, options.majorLabeledNodes, options.categoryLabelSettings, options.layout), minorLabels = this.animateDefaultMinorLabels(options.labelGraphicsContext, options.minorLabeledNodes, options.dataLabelSettings, options.layout);
            return {
                failed: !1,
                shapes: shapes,
                highlightShapes: highlightShapes,
                majorLabels: majorLabels,
                minorLabels: minorLabels
            };
        }, WebTreemapAnimator.prototype.animateHighlightedToNormal = function(options) {
            var hasSelection = !!options.interactivityService && options.interactivityService.hasSelection(), shapes = options.shapeGraphicsContext.selectAll("." + util.classes.node).data(options.nodes, function(d) {
                return d.key;
            });
            shapes.enter().append("rect").attr("class", options.layout.shapeClass), shapes.transition().duration(this.animationDuration).style("fill", function(d) {
                return util.getFill(d, !1);
            }).style("fill-opacity", function(d) {
                return ColumnUtil.getFillOpacity(d.selected, !1, d.selected, !d.selected);
            }).attr(options.layout.shapeLayout).transition().duration(0).delay(this.animationDuration).style("fill-opacity", function(d) {
                return ColumnUtil.getFillOpacity(d.selected, !1, hasSelection, !1);
            }), shapes.exit().remove();
            var highlightShapes = options.shapeGraphicsContext.selectAll("." + util.classes.highlight).data(options.nodes, function(d) {
                return d.key + "highlight";
            });
            highlightShapes.enter().append("rect").attr("class", options.layout.highlightShapeClass), 
            highlightShapes.style("fill", function(d) {
                return util.getFill(d, !0);
            }).style("fill-opacity", function(d) {
                return ColumnUtil.getFillOpacity(d.selected, !0, d.selected, !d.selected);
            }).transition().duration(this.animationDuration).attr(hasSelection ? options.layout.zeroShapeLayout : options.layout.shapeLayout).remove(), 
            highlightShapes.exit().remove();
            var majorLabels = this.animateDefaultMajorLabels(options.labelGraphicsContext, options.majorLabeledNodes, options.categoryLabelSettings, options.layout), minorLabels = this.animateDefaultMinorLabels(options.labelGraphicsContext, options.minorLabeledNodes, options.dataLabelSettings, options.layout);
            return {
                failed: !1,
                shapes: shapes,
                highlightShapes: highlightShapes,
                majorLabels: majorLabels,
                minorLabels: minorLabels
            };
        }, WebTreemapAnimator.prototype.animateDefaultShapes = function(context, nodes, hasSelection, hasHighlights, layout) {
            var isHighlightShape = !1, shapes = context.selectAll("." + util.classes.node).data(nodes, function(d) {
                return d.key;
            });
            return shapes.enter().append("rect").attr("class", layout.shapeClass), shapes.transition().duration(this.animationDuration).style("fill", function(d) {
                return util.getFill(d, isHighlightShape);
            }).style("fill-opacity", function(d) {
                return util.getFillOpacity(d, hasSelection, hasHighlights, isHighlightShape);
            }).attr(layout.shapeLayout), shapes.exit().remove(), shapes;
        }, WebTreemapAnimator.prototype.animateDefaultHighlightShapes = function(context, nodes, hasSelection, hasHighlights, layout) {
            var isHighlightShape = !0, highlightShapes = context.selectAll("." + util.classes.highlight).data(nodes, function(d) {
                return d.key + "highlight";
            });
            return highlightShapes.enter().append("rect").attr("class", layout.highlightShapeClass), 
            highlightShapes.transition().duration(this.animationDuration).style("fill", function(d) {
                return util.getFill(d, isHighlightShape);
            }).style("fill-opacity", function(d) {
                return util.getFillOpacity(d, hasSelection, hasHighlights, isHighlightShape);
            }).attr(layout.highlightShapeLayout), highlightShapes.exit().remove(), highlightShapes;
        }, WebTreemapAnimator.prototype.animateDefaultMajorLabels = function(context, nodes, labelSettings, layout) {
            var labels = context.selectAll("." + util.classes.major).data(nodes, function(d) {
                return d.key;
            });
            return labels.enter().append("text").attr("class", layout.majorLabelClass), labels.text(layout.majorLabelText).style(visuals.FontProperties.toSVGStyle(labelSettings.fontProperties)).transition().duration(this.animationDuration).attr(layout.majorLabelLayout), 
            labels.exit().remove(), labels;
        }, WebTreemapAnimator.prototype.animateDefaultMinorLabels = function(context, nodes, labelSettings, layout) {
            var labels = context.selectAll("." + util.classes.minor).data(nodes, function(d) {
                return d.key;
            });
            return labels.enter().append("text").attr("class", layout.minorLabelClass), labels.text(layout.minorLabelText).style(visuals.FontProperties.toSVGStyle(labelSettings.fontProperties)).transition().duration(this.animationDuration).attr(layout.minorLabelLayout), 
            labels.exit().remove(), labels;
        }, WebTreemapAnimator;
    }(BaseAnimator);
    exports.WebTreemapAnimator = WebTreemapAnimator;
}), define("TreemapVisual/treemapBehaviors", [ "require", "exports", "TreemapVisual/util" ], function(require, exports, util) {
    Object.defineProperty(exports, "__esModule", {
        value: !0
    });
    var pbi = powerbi, visuals = pbi.visuals, InteractivityUtils = visuals.InteractivityUtils, TreemapWebBehavior = function() {
        function TreemapWebBehavior() {}
        return TreemapWebBehavior.prototype.bindEvents = function(options, selectionHandler) {
            var shapes = this.shapes = options.shapes, highlightShapes = this.highlightShapes = options.highlightShapes, majorLabels = options.majorLabels, minorLabels = options.minorLabels;
            this.hasHighlights = options.hasHighlights, InteractivityUtils.registerStandardInteractivityHandlers(shapes, selectionHandler), 
            InteractivityUtils.registerStandardInteractivityHandlers(highlightShapes, selectionHandler), 
            majorLabels && InteractivityUtils.registerStandardInteractivityHandlers(majorLabels, selectionHandler), 
            minorLabels && InteractivityUtils.registerStandardInteractivityHandlers(minorLabels, selectionHandler);
        }, TreemapWebBehavior.prototype.renderSelection = function(hasSelection) {
            var hasHighlights = this.hasHighlights;
            this.shapes.style("fill", function(d) {
                return util.getFill(d, !1);
            }).style("fill-opacity", function(d) {
                return util.getFillOpacity(d, hasSelection, !d.selected && hasHighlights, !1);
            }), this.highlightShapes.style("fill", function(d) {
                return util.getFill(d, !0);
            }).style("fill-opacity", function(d) {
                return util.getFillOpacity(d, hasSelection, !d.selected && hasHighlights, !0);
            });
        }, TreemapWebBehavior;
    }();
    exports.TreemapWebBehavior = TreemapWebBehavior;
}), define("TreemapVisual/util", [ "require", "exports" ], function(require, exports) {
    function getFill(d, isHighlightRect) {
        return d.depth > 1 && !d.identity.hasIdentity() && !isHighlightRect ? CssConstants.noneValue : hasChildrenWithIdentity(d) ? CssConstants.noneValue : d.color;
    }
    function hasChildrenWithIdentity(node) {
        var children = node.children;
        if (!children) return !1;
        var count = children.length;
        if (0 === count) return !1;
        for (var i = count - 1; i >= 0; i--) if (children[i].identity.hasIdentity()) return !0;
        return !1;
    }
    function getFillOpacity(d, hasSelection, hasHighlights, isHighlightRect) {
        return hasHighlights ? isHighlightRect ? null : .4.toString() : !hasSelection || d.selected ? null : d.depth > 1 && d.parent.selected ? null : hasChildrenWithIdentity(d) ? null : .4.toString();
    }
    Object.defineProperty(exports, "__esModule", {
        value: !0
    });
    var CssConstants = jsCommon.CssConstants;
    exports.classes = {
        node: "treemapNode",
        highlight: "treemapNodeHighlight",
        major: "majorLabel",
        minor: "minorLabel"
    }, exports.getFill = getFill, exports.hasChildrenWithIdentity = hasChildrenWithIdentity, 
    exports.getFillOpacity = getFillOpacity;
});